import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
   {
    path: '/',
   component: () => import('@/views/layout/index.vue'),
    redirect: '/home'
  },
   // 当打开项目时，重定向到 /home
    {
      path: '/home',
      component: () => import('@/views/layout/index.vue'),
      children: [
        {
      path: '', //浏览器访问 / 时，默认渲染
      component: () => import('@/views/home/index.vue'),
        },
        {
        path:'words',
        component: () => import('@/views/Words/index.vue')
        },
        //  words/:id? 表示，必须要传参数。如果不传参数，也希望匹配，可以加个可选符 "?" */
        {path:'words/:key',
        component: () => import('@/views/WordDetailed/index.vue')
        },
        {
        path:'login',
          component: () => import('@/views/login/index.vue')
        },
         {
        path:'redirect',
          component: () => import('@/views/redirect/index.vue')
        },
         {
        path:'setting/info',
          component: () => import('@/views/setting/info.vue')
        },
        {
        path:'setting/learn',
          component: () => import('@/views/setting/learn.vue')
        },
        {
         path:'task',
          component: () => import('@/views/task/index.vue')
        },
         {
         path:'statistics',
          component: () => import('@/views/statistics/index.vue')
        }
      ]
    }
  ]
})

export default router
